﻿layui.define(['jquery'], function (exports) {
    $ = layui.$;

    var $body = $('body');

    var module = {
        controllPermisson: function () {
            
            $.post('/Admin/AccountManage/GetUserClaim',
                function (rtnResult) {
                    if (rtnResult.code !== 0) {
                       
                    } else {
                        var operatePermisson = $body.find('*[operate-permisson]');
                        layui.each(operatePermisson,
                            function (operateIndex, operate) {
                                var operatePermissionAttr = $(operate).attr('operate-permisson');
                                var isHasOperatePermisson = false;
                                rtnResult.data.forEach(function (permisson, permissonIndex) {
                                    if (permisson.ClaimValue === operatePermissionAttr) {
                                        isHasOperatePermisson = true;
                                    }
                                });
                                if (!isHasOperatePermisson) {
                                    $(operate).addClass('layui-hide');
                                }
                            });
                    }
                });
        }
    }

    exports('permisson', module);
})